/**
 * @description 存储数据
 * @param {*} key 本地缓存中的key
 * @param {*} value 需要缓存的数据
 */
// 存储数据
export const setStorage = (key, value) => {
    try {
        wx.setStorageSync(key, value)
    } catch (error) {
        console.log(`存储指定${key}数据发生了异常`, error);
    }
}
// 获取数据
export const getStorage = (key) => {
    try {
        wx.getStorageSync(key)
    } catch (error) {
        console.log(`读取指定${key}数据发生了异常`, error);
    }
}
// 移除数据
export const removeStorage = (key) => {
    try {
        wx.removeStorageSync(key)
    } catch (error) {
        console.log(`移除指定${key}数据发生了异常`, error);
    }
}
// 清空数据
export const clearStorage = (key) => {
    try {
        wx.clearStorageSync(key)
    } catch (error) {
        console.log(`清空数据发生了异常`, error);
    }
}
// 异步
export const asyncSetStorage = (key, value) => {
    return new Promise(resolve => {
        wx.setStorage({
            key,
            value,
            complete(res){
                resolve(res)
            }
        })
    })
}
export const asyncGetStorage = (key) => {
    return new Promise(resolve => {
        wx.getStorage({
            key,
            complete(res){
                resolve(res)
            }
        })
    })
}
export const asyncRemoveStorage = (key) => {
    return new Promise(resolve => {
        wx.removeStorage({
            key,
            complete(res){
                resolve(res)
            }
        })
    })
}
export const asyncClearStorage = (key) => {
    return new Promise(resolve => {
        wx.clearStorage({
            key,
            complete(res){
                resolve(res)
            }
        })
    })
}